package com.catt.orderdinner.service.impl;

import com.catt.orderdinner.dataobject.TbProject;
import com.catt.orderdinner.repository.TbProjectRepository;
import com.catt.orderdinner.service.ProjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProjectServiceImpl implements ProjectService {

    @Autowired
    private TbProjectRepository tbProjectRepository;

    @Override
    public List<TbProject> findAll() {
        return tbProjectRepository.findAll();
    }

    @Override
    public Page<TbProject> findAll(Pageable pageable) {
        return tbProjectRepository.findAll(pageable);
    }

    @Override
    public TbProject findOneByUserId(String projectId) {
        return tbProjectRepository.findByProjectId(projectId);
    }

    @Override
    public void save(TbProject project) {
        tbProjectRepository.save(project);
    }

    @Override
    public void del(String id) {
        tbProjectRepository.deleteById(id);
    }
}
